# coding=utf-8
from sqlalchemy import Column, Integer, String, BigInteger, Float

from db_models.orm_base import BaseOrmClass


class QuestionsDeleted(BaseOrmClass):
    '''
    模型(表)备注:
问题
    '''
    __tablename__ = 'questions_deleted'

    '''      '''
    id = Column(BigInteger(), primary_key=True)

    '''   题目   '''
    title = Column(String(), nullable=False)

    '''   选项   '''
    options = Column(String(), nullable=False)

    '''   区分度   '''
    a = Column(Float(), nullable=False)

    '''   难度   '''
    b = Column(Float(), nullable=False)

    '''   低水平也能功过概率   '''
    c = Column(Float(), nullable=False)

    '''   高水平仍然不能通过概率   '''
    d = Column(Float(), nullable=False)

    '''   信息量   '''
    info = Column(Float(), nullable=False)

    '''   标准答案(小写)   '''
    answer = Column(String(9))

    '''   曝光度   '''
    exp_rate = Column(Float(), nullable=False)

    '''   曝光次数   '''
    exp_num = Column(Integer())

    '''   试题类型   '''
    type = Column(String(45), nullable=False)

    '''   所属能力ID   '''
    aid = Column(Integer(), nullable=False)

    def exclude(self): return ('a', 'b', 'c', 'info')

    @staticmethod
    def create(question):
        item = QuestionsDeleted()
        for f in ('id', 'title', 'options', 'a', 'b', 'c', 'd', 'info', 'answer', 'exp_rate', 'exp_num', 'type', 'aid'):
            setattr(item, f, getattr(question, f))
        return item
